package android.support.v4.os;

import android.app.DownloadManager;

/**
 * 控制应用调用系统下载
 */
public class EDownloadManager extends EHook {

	@Override
	public String getClassName() {
		return DownloadManager.class.getName();
	}

	@Override
	public void hook() {
		super.hook();

		// public long enqueue(Request request)
		findAndHookMethod("enqueue", DownloadManager.Request.class, this);
	}

	@Override
	protected boolean before(String name, Object[] args, MethodHookParam param) {
		if ("enqueue".equals(name)) {
			log.e("DownloadManager", "req download:" + args[0]);
			param.setResult(0L); // 返回 long 类型
			return true;
		}

		return super.before(name, args, param);
	}
}
